<?php
namespace Tools;

use \Imp\weixin\weixin;

class weixin_tools {
	public function requestWeixinLogin($redirect_url){
		$weixin = new weixin;
		if (!isset($_GET["code"])){
		    $jumpurl = $weixin->oauth2_authorize($redirect_url, "snsapi_userinfo", "123");
		    // dump($jumpurl);
		    Header("Location: $jumpurl");
		}else{
		    $access_token_oauth2 = $weixin->oauth2_access_token($_GET["code"]);
		    $userinfo = $weixin->oauth2_get_user_info($access_token_oauth2['access_token'], $access_token_oauth2['openid']);
		    // dump( $userinfo );
		}
	}
}